/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package solitaireofdoom.solitaire;

import java.awt.image.*;
import java.util.Stack;
import java.util.Vector;

/**
 * All of the freecell piles (FreecellCellPile, FreecellFoundationPile, and FreecellTableuPile) inherit the Pile class, serve basic pile functions, and accept cards as well as discard them. They have DropTarget event listeners that are fired when a CardCanvas is dropped on them, it containsthe logic that checks if the pile can accept the cards that are being dropped.
 *
 * @author Administrator
 */
public class Pile extends javax.swing.JComponent
{
    public BufferedImage cards;
    public Vector<CardCanvas> pileCards;

    public Pile()
    {
        super();
        this.pileCards = new Stack<CardCanvas>();
    }

    /**
     * Removes card from pile
     *
     * @param cc <b>CardCanvas</b>
     */
    public void remove(CardCanvas cc)
    {
        CardCanvas current = null;

        while (!pileCards.isEmpty())
        {
            current = this.pileCards.lastElement();
            pileCards.remove(current);

            if (cc == current)
                break;
        }

        this.redraw();
    }

    /**
     * Removes all the cards from this pile
     */
    public void clear()
    {
        this.pileCards.clear();

        this.redraw();
    }

    /**
     * Is inherited by all of the piles and displays the cards differently for each pile
     */
    public void redraw()
    {
        // Ekkert :O
    }

    /**
     * Reports that a card has been clicked
     * @param isTopMost
     */
    public void cardClicked(boolean isTopMost)
    {
        // Ekkert :O
    }
}
